import store from "@/store";
import { rootPath, isDev } from "@/configurations";
/**
 * @name 获取权限
 * @param {string} routePath 页面路由路径
 * @returns {Array} 权限列表
 * @description 根据路由路径获取该用户在该路径页面上所拥有的权限
 */
export default function checkPermission(routePath) {
  const permissions = store.state.user.permissions;
  routePath = routePath.replace(new RegExp(`/^${rootPath}/`), "");
  const result = [""];
  permissions.forEach(permission => {
    if (permission.includes(routePath)) {
      result.push(permission.replace(routePath, ""));
    }
  });
  //   return result;
  return ["edit", "remove", "add"];
}
